<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">
		<link rel="stylesheet" type="text/css" th:href="@{/static/layui/css/layui.css}" />
		<link rel="stylesheet" type="text/css" th:href="@{/static/css/organization/thesame.css}" />
		<link rel="stylesheet" type="text/css" th:href="@{/static/css/footer.css}" media="all">
		<link rel="stylesheet" type="text/css" th:href="@{/static/css/wardRound/rightCon.css}" media="all" />
		<link rel="stylesheet" type="text/css" th:href="@{/static/css/wardRound/popCss.css}" media="all" />

	</head>
	<body class="layui-layout-body">
	<input id="userNo" type="hidden" name="userNo" th:value="${userNo}" />
	<input id="batchNo" type="hidden" name="batchNo" th:value="${batchNo}" />
		<div class="layui-body">
			<div class="add-title pad25px"><!--<span class="mr10px"><img th:src="@{/static/img/return_icon.png}"></span>--><span>新建档案</span></div>
				<div class="new-add-box new-add-box-width bgWhite box-shadows border-radius4">
					<div class="add-box-scroll">
						<div class="border-bot5px border-radius4 pad25px">
							<dl class="per-look-dl">
								<dt>
									<img th:if="${userInfo['headExist']}==1" th:src="${userInfo['headUrl']}" class="block">
									<img th:if="${userInfo['headExist']}==0" th:src="@{/static/img/defaultHead.jpg}" class="block">
								</dt>
								<dd>
									<div class="overflow">
										<p class="left">
											<span th:text="${userInfo['userName']}"></span>
											<span class="border-bggray" th:text="${userInfo['bedInfo']}"></span>
										</p>
										<p class="right">
											<span class="border-bgred" th:if="${userInfo['cognitionStatus']}==1">认知问题</span>
											<span th:onclick="nursingLevelPicLayerOpen([[${userInfo.nursingImg}]])" class="border-bgred cursor">
												<em th:text="${userInfo['nursingDegree']}"></em>
												<em class="look-em border-bgred textCenter">?</em>
											</span>
											<span class="border-bgred" th:text="${userInfo['assessmentDegree']}"></span>
										</p>
									</div>
									<div>
										<span th:text="${userInfo['userSex']}"></span>
										<span th:text="${userInfo['userAge']}+'岁'"></span>
										<span th:text="${userInfo['eduction']}"></span>
										<span th:text="${userInfo['securityType']}"></span>
										<span th:text="${userInfo['userAddress']}"></span>
									</div>
									<div>
										<span class="border-bggreen" th:text="'合同截止：'+${userInfo['contractEndDate']}"></span>
										<span class="border-bggreen" th:text="'下次护理评估时间：'+${userInfo['nursingDate']}"></span>
										<span class="border-bggreen" th:text="'评估有效期：'+${userInfo['assessmentDate']}"></span>
									</div>
								</dd>
							</dl>
						</div>
						<div class="mb25px pad25px">
							<ul class="inform-title mb25px">
								<li class="current" style="cursor: default">健康档案</li>
								<li class="current" style="cursor: default">体格检查</li>
								<li class="current" style="cursor: default">实验室检查</li>
								<li class="current" style="cursor: default">初步诊断</li>
								<li style="cursor: default">诊疗计划</li>
							</ul>
							<article class="mb25px">
								<ul class="add-bed mt15px overflow lh32px" id="dataUl" style="margin-bottom: 20px">
									<li th:each="item : ${checkInfo_select}" th:data-id="${item.checkNo}"><span>[[${item.checkName}]]</span><em class="removeLi"><img src="../static/elderlyInfo/img/delete_bed.png"></em></li>
									<p class="left green border-radius4 textCenter pl20px pr20px cursor" id="addButton"><img src="../static/elderlyInfo/img/icon_xuqian.png" alt="添加">添加</p>
								</ul>
								<div class="new-add-form-con new-add-form-three">
									<ul class="overflow">
										<li class="width-three">
											<p><label>其他说明：</label></p>
											<p>
												<textarea placeholder="其他说明(1000字以内)" id="qitashuoming" maxlength="1000" rows="5" cols="5" class="layui-textarea resize" th:value="${preliminaryDiagnosis?.diseaseText}" th:text="${preliminaryDiagnosis?.diseaseText}">暂无</textarea>
											</p>
										</li>
									</ul>
								</div>
							</article>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="layui-footer layui-footer-one">
			<div class="btn-con textCenter">
				<span class="btn-three cursor" id="prevButton">上一步</span>
				<span class="btn-two cursor" id="nextButton">下一步</span>
			</div>
		</div>
		<div id="checkInfoDiv" style="display: none;">
			<li th:each="item:${checkInfo}" th:data-id="${item.checkNo}" th:data-name="${item.checkName}">[[${item.checkName}]]</li>
		</div>
		<div id="pop-nursingLevelPicLayerOpen" style="display: none;">
			<div class="pop-up">
				<!-- 查看护理等级 -->
				<div>
					<div class="pop-title relative overflow mb15px">
						<span class="ml15px">护理等级</span>
						<p class="right"><img src="../static/elderlyInfo/img/close_icon.png" class="block pop-close"><p>
					</div>
					<div class="mt10px">
						<p><img id="nursingPic" th:src="${userInfo.nursingImg}" alt=""></p>
					</div>
				</div>
			</div>
		</div>

		<script th:src="@{/static/js/jquery-2.1.3.min.js}"></script>
		<script th:src="@{/static/js/nursingImg.js}"></script>
		<script th:src="@{/static/layui/layui.js}"></script>
		<script>
			var basePath = $("input#basePathInput",parent.document).val();
			var saveFlag = true;

			//左侧菜单栏
			layui.use(['element' , 'form' , 'laydate','layer'], function() {
				var element = layui.element;
				var form = layui.form;
				var layer = layui.layer;
				//弹层
				$("span#prevButton").on("click",function (e) {
					window.location.href=basePath+"/wardRound/wardRound_three"+"?userNo="+$("#userNo").val()+"&batchNo="+$("input#batchNo").val();
				})

				$("span#nextButton").on("click",function (e) {
					let flag = true;
					let data = "";
					$("ul#dataUl li").each(function (i,v) {
						let id = $(this).data("id");
						data += id + ",";
					})
					let text = $("textarea#qitashuoming").val();
					if(!isNotNull(data) && !isNotNull(text)){
						flag = false;
						layer.msg("病情类型和其他说明至少填写一项！");
						return false;
					}
					if(data){data = data.substring(0,data.length - 1);}
					if (flag) {
						if (saveFlag) {
							saveFlag = false;
							$.ajax({
								url: "../wardRound/savePreliminaryInspection",
								type: "post",
								dataType: "json",
								data: {"batchNo": $("input#batchNo").val(), "data": data,"text":text},
								success: function (result) {
									saveFlag = true;
									if (result.code == 200) {
										window.location.href=basePath+"/wardRound/wardRound_five?batchNo="+$("input#batchNo").val()+"&userNo="+$("input#userNo").val();
									}else{
										layer.msg(result.msg);
									}
								}
							})
						}
					}
				})

				$("p#addButton").unbind().on("click",function (e) {
					layerOpen();
				})

				function layerOpen(){
					let html = '<div id="pop-con"><div class="pop-up"><div><div class="pop-title relative overflow mb15px"><span class="ml15px">添加</span><p class="right"><img src="../static/img/close_icon.png" class="block pop-close"><p></div><nav class="add-person mt20px mb10px"><ul id="checkInfoUl">';
					html += $("div#checkInfoDiv").html();
					html += '</ul></nav><div class="btn-con textCenter"><span class="btn-one pop-close cursor">取&nbsp;消</span><span class="btn-two cursor" id="submitSelectButton">确&nbsp;定</span></div></div></div></div>'
					layer.open({
						type: 1,
						title: false, //不显示标题栏
						closeBtn: false,
						area: ['520px', ''],
						shade: 0.6,
						id: 'payCons',
						btnAlign: 'c',
						moveType: 1,
						shadeClose: true,
						content: html,
						success: function() {
							//关闭弹层
							$(".pop-close").click(function() {
								layer.closeAll();
							});

							$('.add-person ul li').click(function(){
								$(this).toggleClass('cur-green');
							})

							$("span#submitSelectButton").on("click",function (e) {
								let html = "";
								$("ul#checkInfoUl li.cur-green").each(function (i,v) {
									let id = $(this).data("id");
									let name = $(this).data("name");
									html += '<li data-id="'+id+'"><span>'+name+'</span><em class="removeLi"><img src="../static/elderlyInfo/img/delete_bed.png"></em></li>';
								})
								$("ul#dataUl").html(html+'<p class="left green border-radius4 textCenter cursor pl20px pr20px" id="addButton"><img src="../static/elderlyInfo/img/icon_xuqian.png" alt="添加">添加</p>');
								layer.closeAll();
								$("p#addButton").unbind().on("click",function (e) {
									layerOpen();
								})
								$("em.removeLi").unbind().on("click",function (e) {
									$(this).parent().remove();
								})
							})
						}
					});
				}
			});

			function isNotNull(val) {
				if(val && $.trim(val) && val != 'undefined' && val != 'null'){
					return true;
				}else{
					return false;
				}
			}
		</script>
	</body>

</html>
